function setFont() {
  let htmlWidth = document.querySelector('html').clientWidth
  if (htmlWidth < 1024) htmlWidth = 1024
  if (htmlWidth > 1920) htmlWidth = 1920
  let fontSize = htmlWidth / 80 + 'px'
  document.querySelector('html').style.fontSize = fontSize
}
setFont()
window.onresize = function () {
  setFont()
}
let xm
let pf
let xz
let xm1 = []
let pf1 = []
let xz1 = []
//点击添加
$('.tianjia').on('click', function () {
  xm = $('.xingming input').val()
  pf = $('.pingfen input').val()
  xz = $('.xinzi input').val()
  let td = $(`
  <tr>
  <td>${xm}</td>
  <td>${pf}</td>
  <td>${xz}</td>
  </tr>
  `)
  $('.btn table').append(td)
  $('.xingming input').val('')
  $('.pingfen input').val('')
  $('.xinzi input').val('')
  xm1.push(xm)
  pf1.push(pf)
  xz1.push(xz)
  arr()
  _arr()
})

//折线图
function arr() {
  let myChart = echarts.init($('.right .box')[0])
  let option = {
    xAxis: {
      type: 'category',
      data: xm1
    },
    yAxis: {
      type: 'value'
    },
    series: [{
      data: pf1,
      type: 'line'
    }]
  }
  myChart.setOption(option)
}



//柱状图
function _arr() {
  let myChart = echarts.init($('.right .nav')[0])
  let option = {
    xAxis: {
      type: 'category',
      data: xm1,
    },
    yAxis: {
      type: 'value'
    },
    series: [{
      data: xz1,
      type: 'bar',
      barWidth: 40,
    }]
  }
  myChart.setOption(option)
}
